package com.aspose.cells.b.a.d;

import com.aspose.cells.Encoding;

public class za {
   private zm b;
   private byte[] c;
   private Encoding d;

   public za(zm var1) {
      this.d = Encoding.getUnicode();

      assert var1 != null;

      this.b = var1;
      this.c = new byte[16];
   }

   public za(zm var1, Encoding var2) {
      this(var1);

      assert var2 != null;

      this.d = var2;
   }

   public zm k() {
      return this.b;
   }

   public void l() throws Exception {
      this.b.a();
   }

   public int a(byte[] var1, int var2, int var3) throws Exception {
      return this.b.a(var1, var2, var3);
   }

   public byte[] g(int var1) throws Exception {
      if (var1 < 0) {
         throw new IllegalArgumentException("count");
      } else {
         byte[] var2 = new byte[var1];
         int var3 = 0;

         do {
            int var4 = this.b.a(var2, var3, var1);
            if (var4 == 0) {
               break;
            }

            var3 += var4;
            var1 -= var4;
         } while(var1 > 0);

         if (var3 != var2.length) {
            byte[] var5 = new byte[var3];
            System.arraycopy(var2, 0, var5, 0, var3);
            var2 = var5;
         }

         return var2;
      }
   }

   public byte m() throws Exception {
      this.a(1);
      return this.c[0];
   }

   public short n() throws Exception {
      this.a(2);
      return (short)(this.c[0] & 255 | (this.c[1] & 255) << 8);
   }

   public boolean o() throws Exception {
      this.a(1);
      return this.c[0] != 0;
   }

   public int p() throws Exception {
      return this.n() & '\uffff';
   }

   public int q() throws Exception {
      this.a(4);
      return this.c[0] & 255 | (this.c[1] & 255) << 8 | (this.c[2] & 255) << 16 | (this.c[3] & 255) << 24;
   }

   public long r() throws Exception {
      return (long)this.q() & 4294967295L;
   }

   public long s() throws Exception {
      long var1 = this.r();
      long var3 = this.r();
      return var3 << 32 | var1;
   }

   public float t() throws Exception {
      return Float.intBitsToFloat(this.q());
   }

   public double u() throws Exception {
      return Double.longBitsToDouble(this.s());
   }

   private void a(int var1) throws Exception {
      if (var1 > 0 && var1 <= this.c.length) {
         int var2 = 0;

         do {
            int var3 = this.b.a(this.c, var2, var1 - var2);
            if (var3 == 0) {
               throw new IllegalStateException("End of file reached.");
            }

            var2 += var3;
         } while(var2 < var1);

      } else {
         throw new IllegalArgumentException("numBytes");
      }
   }
}
